package cn.myspringboot.comment.service.impl;

import cn.myspringboot.comment.dao.CommentRepository;
import cn.myspringboot.comment.service.CommentService;
import cn.myspringboot.user.domain.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentRepository commentRepository;

    @Override
    public void saveComment(Comment comment) {
        commentRepository.save(comment);
    }

    @Override
    public List<Comment> findCommentByBlogId(Long articleId) {
        return commentRepository.findByArticleId(articleId);
    }

    @Override
    public void updateComment(Comment comment) {
        commentRepository.save(comment);
    }

    @Override
    public void deleteCommentById(String id) {
        commentRepository.deleteById(id);
    }

    @Override
    public List<Comment> findAllComment() {
        return commentRepository.findAll();
    }
}
